home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
LOGIC Apps
/
Logic-APPLE_II_APPS.iso
/
mac
/
LOGIC Apple II 5.25" Library - ProDOS
/
PRO050.dsk
/
CALC.bas
< prev
next >
Wrap
BASIC Source File
|
2012-02-16
|
2KB
|
52 lines
10 D$ = CHR$(4)
30 ONERR GOTO 500
40 HOME
50 PRINT
60 HTAB 20: VTAB 4: PRINT "ENTER YOUR CALCULATION, THEN PRESS <RETURN>"
70 H = 1:I = 1:PW$ = "":IN$ = "":F = 0:V = 7:M = 0:G = 0
80 HTAB 2: VTAB 7: CALL -958: PRINT PW$
90 H = LEN(PW$) +2: IF H >79 THEN M = INT(H/79 +.001):V = 7 +M
95 HTAB H: VTAB V: GET X$
100 IF X$ = "+" THEN 200
110 IF F = 1 THEN F = 1: IF X$ = "-" THEN 190
120 IF X$ = "-" THEN 200
130 IF X$ = "*" THEN 200
140 IF X$ = "/" THEN 200
150 IF X$ = "." THEN 190
155 IF X$ = "0" THEN 190
160 IF X$ = CHR$(8) OR X$ = CHR$(127) THEN G = 1: IF LEN(IN$) <1 THEN 169
162 IF G = 1 THEN G = 1: IF LEN(IN$) = 1 THEN IN$ = "":G = 2: IF LEN(PW$) >1 THEN PW$ = LEFT$(PW$, LEN(PW$) -1): GOTO 169
164 IF G = 2 THEN PW$ = "": GOTO 169
166 IF G = 1 THEN IN$ = LEFT$(IN$, LEN(IN$) -1):PW$ = LEFT$(PW$, LEN(PW$) -1): GOTO 169
169 IF G = 1 OR G = 2 THEN G = 0: GOTO 80
170 IF X$ = CHR$(13) OR X$ = CHR$(61) THEN SI$(I) = "z":NB$(I) = IN$: GOTO 220
175 IF X$ = CHR$(27) THEN 70
180 IF VAL(X$) <1 THEN 80
190 IN$ = IN$ +X$:PW$ = PW$ +X$:F = 0: GOTO 80
200 NB$(I) = IN$:SI$(I) = X$:I = I +1:PW$ = PW$ +" " +X$ +" ":IN$ = "":F = 1: IF I = 20 THEN 310
210 GOTO 80
220 I = 1
230 AN = VAL(NB$(I))
240 IF SI$(I) = "+" THEN AN = AN + VAL(NB$(I +1)): GOTO 290
250 IF SI$(I) = "-" THEN AN = AN - VAL(NB$(I +1)): GOTO 290
260 IF SI$(I) = "*" THEN AN = AN * VAL(NB$(I +1)): GOTO 290
270 IF SI$(I) = "/" THEN AN = AN/ VAL(NB$(I +1)): GOTO 290
280 IF SI$(I) = "z" THEN 300
290 I = I +1: GOTO 240
300 HTAB H: VTAB V: PRINT " = ";AN:AN = 0: GOTO 320
310 HTAB 32: VTAB 18: PRINT "TOO MANY ENTRIES"
320 HTAB 30: VTAB 20
330 PRINT "ANOTHER CALCULATION?"
340 HTAB 40: VTAB 22: GET X$
350 IF X$ = "Y" OR X$ = "y" THEN 40
360 IF X$ = "N" OR X$ = "n" THEN 400
370 IF X$ < >"n" THEN 320
400 F = 0:H = 0:IN$ = ""
410 IF FK = 1 THEN FK = 0: POKE 216,0: PRINT D$;"CHAIN /RAM/CW,@5005"
420 IF FK = 2 THEN FK = 0: POKE 216,0: PRINT D$;"CHAIN /RAM/RPT"
430 POKE 216,0: PRINT D$;"CHAIN /RAM/CW,@4005"
500 REM ERROR HANDLER
510 IF PEEK(222) = 133 THEN CALL -3288
520 HTAB 30: VTAB 13: PRINT CHR$(34);"YOU'RE UNDER ARREST"; CHR$(34)
530 HTAB 27: PRINT "DIVISION BY ZERO IS ILLEGAL"
540 GOTO 320